define(["../layers/GraphicsLayer", "../others/EventDrive", "../symbols/TextSymbol", "../symbols/PrimitiveSymbol", "../Graphic", "../_Color", "../../Source/Scene/LabelStyle", "../../Source/Scene/HorizontalOrigin", "../../Source/Scene/VerticalOrigin", "../../Source/Core/Cartesian3", "../../Source/Core/defaultValue"], (function (e, t, i, s, o, h, l, r, n, a, c) {
  function p(i) {
    this.viewer = i.viewer, this.actis = i.actis, this.showLabel = i.showLabel, this.viewer.scene.globe.depthTestAgainstTerrain = !0, this.layer = new e({
      viewer: i.viewer
    }), this.circles = [], this.path = [], this.height = [], this.lines = null, this.label = [], this.point = this.viewer.entities.add({
      point: {
        color: h("red"),
        pixelSize: 10
      }
    }), this.labelTotle = this.viewer.entities.add({
      label: {
        show: !1,
        showBackground: !0,
        font: "36px Helvetica",
        fillColor: h("WHITE"),
        outlineColor: h("BACK"),
        outlineWidth: 5,
        style: l.FILL_AND_OUTLINE,
        horizontalOrigin: r.CENTER,
        verticalOrigin: n.BASELINE,
        disableDepthTestDistance: 1e4,
        scale: .5
      }
    }), this.event = new t({
      viewer: this.viewer,
      eventType: "left_click",
      callBack: e => {
        let t = this.path,
          i = this.movePoint.mapPoint.longitude,
          p = this.movePoint.mapPoint.latitude,
          w = this.movePoint.mapPoint.height + 150,
          v = 0,
          d = 0;
        if (w < -50) return;
        t.push(i, p), this.height.push(w);
        let u = t.length,
          m = new o({
            symbol: {
              type: "point-3d",
              style: {
                type: "cone",
                height: 60,
                width: 30,
                color: "#4af99d"
              }
            },
            geometry: {
              type: "point",
              longitude: i,
              latitude: p,
              height: w + 30
            }
          }),
          g = new s({
            type: "circle",
            center: [i, p],
            radius: .5,
            color: "#4af99d",
            class: "both"
          }),
          b = new s({
            type: "line",
            ranges: t,
            color: "red",
            width: 1,
            class: "both"
          });
        if (this.layer.add(m), this.viewer.map.remove(this.lines), this.circles.push(g), this.lines = b, this.viewer.map.add(b), this.viewer.map.add(g), u >= 4) {
          for (let e = u - 1; e >= 3; e -= 2) v += Math.sqrt(a.distanceSquared(new a.fromDegrees(t[e - 1], t[e]), new a.fromDegrees(t[e - 3], t[e - 2])));
          d = Math.sqrt(a.distanceSquared(new a.fromDegrees(t[u - 2], t[u - 1]), new a.fromDegrees(t[u - 4], t[u - 3]))), this.labelTotle.position = new a.fromDegrees(t[0], t[1], this.height[0] + 10), this.labelTotle.show = c(this.showLabel, !0), this.labelTotle.label.show = !0, this.labelTotle.label.text = "总长：" + v.toFixed(2) + " 米";
          this.actis(this.labelTotle)
          let e = this.viewer.entities.add({
            show: c(this.showLabel, !0),
            position: new a.fromDegrees((t[u - 2] + t[u - 4]) / 2, (t[u - 1] + t[u - 3]) / 2, this.height[u / 2 - 1] + 10),
            label: {
              show: !0,
              text: d.toFixed(2) + "米",
              showBackground: !0,
              font: "36px Helvetica",
              fillColor: h("WHITE"),
              outlineColor: h("BACK"),
              outlineWidth: 5,
              style: l.FILL_AND_OUTLINE,
              horizontalOrigin: r.CENTER,
              verticalOrigin: n.BASELINE,
              disableDepthTestDistance: 1e4,
              scale: .5
            }
          });
          this.label.push(e)
        }
        this.viewer.scene.requestRenderMode = !1
      }
    }), this.mouseMove = new t({
      eventType: "mouse_move",
      viewer: i.viewer,
      callBack: e => {
        this.movePoint = e, this.point && (this.point.position = e.cartesian)
      }
    })
  }
  return p.prototype.destroy = function () {
    this.viewer.scene.globe.depthTestAgainstTerrain = !1, this.viewer.entities.remove(this.labelTotle), this.viewer.entities.remove(this.point), this.label.forEach(e => this.viewer.entities.remove(e)), this.viewer.map.remove(this.lines), this.circles.forEach(e => this.viewer.map.remove(e)), this.event.destroy(), this.mouseMove.destroy(), this.height = [], this.circles = [], this.point = null, this.path = [], this.lines = null
  }, p.prototype.getPath = function () {
    return this.path
  }, p
}));
